const express=require('express')
const router=express.Router()
const cosToken=require('../../util/cosToken')
//COS 腾讯云存储桶下载token
let data={}
router.get('/cos/costoken',(req,resp,next)=>{
  let date=new Date()
  if(req.user){
    req.query.name=req.query.key+date.getTime()+req.user.uid+'.'+ req.query.name.split('.')[1]
  }else{
    req.query.name=req.query.key+date.getTime()+'.'+ req.query.name.split('.')[1]
  }
  
  data.Authorization=cosToken.getAuthorization(req.query)
  data.uid=req.query.uid
  data.name=req.query.name
  data.code=200
  resp.status(200).json(data)
})
module.exports=router